package com.imooc.distributedemo.resume.coll;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

public class HashMapDemo {

    public static void main(String[] args) {

        Map<String,String> map = new HashMap<>(29);
        System.out.println(map.size());
    }

    public void mapIterator(){
        Map<Integer,String> hs = new HashMap<>();

        int i = 0;
        hs.put(199,"序号："+201);
        while(i<50){
            hs.put(i,"序号"+i);
            i++;
        }
        hs.put(-1,"序号"+200);
        hs.put(200,"序号"+200);

        for (Entry<Integer,String> entry:hs.entrySet()){
            System.out.println(entry.getKey()+"---"+entry.getValue());
        }

        Iterator<Entry<Integer,String>> iter = hs.entrySet().iterator();
        while (iter.hasNext()){
            Entry<Integer,String> theEntry = iter.next();
            System.out.println(theEntry.getKey()+"==="+theEntry.getValue());
        }

        for (Integer key:hs.keySet()){
            Integer hsKey = key;
            String value = hs.get(hsKey);
        }

        Iterator keyIter = hs.keySet().iterator();
        while (keyIter.hasNext()){
            Integer key = (Integer)keyIter.next();

        }
    }
}
